package main

import (
	"crypto/tls"
	"gitee.com/gcom/ths_socket/proxy"
	"gitee.com/gcom/ths_socket/socks5"
	"log"
	"os"
)

func main() {
	//var host = "mobi2.hexin.cn"
	//var port = 9528
	//conn, err := net.Dial("tcp", host + ":" + strconv.Itoa(port))

	cert, err := tls.LoadX509KeyPair("conf/root.pem", "conf/root.key")
	if err != nil {
		log.Fatalf("error loading X509 keypair: %s", err.Error())
	}

	conf := &socks5.Config{
		AuthMethods: []socks5.Authenticator{socks5.NoAuthAuthenticator{}},
		Logger:      log.New(os.Stdout, "", log.LstdFlags),
		Proxy:       proxy.ThsProxy,
		Cert:        &cert,
	}
	serv, err := socks5.New(conf)
	if err != nil {
		log.Fatalf("err: %v", err)
	}
	if err := serv.ListenAndServe("tcp", ":8080"); err != nil {
		log.Fatalf("err: %v", err)
	}
	//proxy.GenerateTls()
}
